package com.xtoneict.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xtoneict.auth.entity.User;
import com.xtoneict.auth.entity.WorkTimeFile;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WorkTimeFileMapper extends BaseMapper<WorkTimeFile> {
    //插入新数据
    @Insert("insert into user_file (user_id,file_id) values (#{arg0}, #{arg1})")
    Integer insertUserAndFile(Integer userId, Integer fileId);

    //删除
    @Delete("delete from user_file where user_id = #{arg0} and file_id = #{arg1}")
    Integer deleteUserAndFile(Integer userId, Integer fileId);

    //根据用户查询
    @Select("select file_id from user_file where user_id = #{userId}")
    List<Integer> selectFileIdsByUser(Integer userId);

    //根据工时表查询
    @Select("select user_id from user_file where file_id = #{fileId}")
    List<Integer> selectUserIdsByFile(Integer fileId);
}
